package com.fg.pro.trade.controller;




import com.fg.pro.model.config.ValidationGroups;
import com.fg.pro.model.reponse.ResponseResult;
import com.fg.pro.model.sys.entity.SysMenu;
import com.fg.pro.trade.entity.TradeCategory;
import com.fg.pro.trade.service.TradeCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;


/**
 * 商品分类(TradeCategory)表控制层
 *
 * @author makejava
 * @since 2025-08-11 14:47:29
 */
@Tag(name = "tradeCategory",description = "商品分类")
@RestController
@RequestMapping("tradeCategory")
public class TradeCategoryController {
    /**
     * 服务对象
     */
    @Resource
    private TradeCategoryService tradeCategoryService;

    @Operation(summary = "获取商品分类树状",description = "")
    @GetMapping("/getTree")
    public ResponseResult getTree(){
        List<TradeCategory> deptList = tradeCategoryService.getTree();
        return ResponseResult.okResult(deptList);
    }

    @Operation(summary = "刷新商品分类树状",description = "参数时间，可以不传参，默认刷新时间当前")
    @PostMapping("/refresh")
    public ResponseResult refresh(@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) throws InterruptedException {
        boolean flag = tradeCategoryService.refresh(date);
        return ResponseResult.okResult(flag?"刷新成功":"正在刷新中。。。");
    }


}

